﻿using System.Collections.Generic;
using BPM.Web.Shared;
using BPM.Web.Shared.Extensions;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.RootComponents.Add<App>("app");
builder.RootComponents.Add<HeadOutlet>("head::after");

var serverUrl = builder.Configuration.GetValue<string>("ServerUrl");
if (string.IsNullOrWhiteSpace(serverUrl))
    serverUrl = builder.HostEnvironment.BaseAddress;

builder.Services.AddBpmBlazor(new Dictionary<string, object> {
    {"ServerUrl",serverUrl },{"BlazorMode","wasm" }
});



////bootstrap组件
//builder.Services.AddBootstrapBlazor(op =>
//{
//    op.DefaultCultureInfo = "zh";
//    op.ToastPlacement = Placement.TopEnd;
//    op.ToastDelay = 5000;
//});
//builder.Services.AddSingleton<ToastService>();

//builder.Services.AddOptions();
//builder.Services.AddBlazoredLocalStorage();
//builder.Services.AddAuthorizationCore();

//builder.Services.AddScoped<AuthorizationMessageHandler>();
//builder.Services.AddHttpClient(clientName, client =>
//{
//    client.BaseAddress = new Uri(serverUri);
//    client.DefaultRequestHeaders.Add("Cache-Control", "no-cache");
//    client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
//}).AddHttpMessageHandler(sp => sp.GetRequiredService<AuthorizationMessageHandler>().ConfigureHandler(new[] { serverUri }));
//builder.Services.AddScoped(sp => sp.GetRequiredService<IHttpClientFactory>().CreateClient(clientName));
//builder.Services.AddScoped<TokenProvider>();
//builder.Services.AddScoped<IHttpManager, HttpManager>();
//builder.Services.AddScoped<IAuthService, AuthService>();
//builder.Services.AddScoped<AuthenticationStateProvider, JwtAuthenticationStateProvider>();
//builder.Services.AddScoped<PageContext>();
//builder.Services.AddSingleton<IIconProvider, FontAwesomeIconProvider>();
//builder.Services.AddScoped<IJSClosableModule, JSClosableModule>();

await builder.Build().RunAsync();
